
package net.pec.geotools_svg.svg_conversion;


import java.io.*;
import java.net.URL;

import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.geotools.data.*;
import org.geotools.feature.*;
import org.opengis.feature.simple.SimpleFeature;

import com.vividsolutions.jts.geom.*;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class GeneratePointElement {

  
public Element transformFeature(SimpleFeature feature, Double midpoint, 
		String[] AttributeType, String[] AttributeValue,Document svgDoc ) throws Exception {
 
  
  Coordinate oneCrd = new Coordinate();
  String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
  Element pointElement = svgDoc.createElementNS(svgNS, "circle");  
  
  if (AttributeType !=null){
	  for(int i=0; i<AttributeType.length; i++){	
		  pointElement.setAttributeNS(null, AttributeType[i],AttributeValue[i]);
	  }
	  }
  
  Geometry geom = (Geometry) feature.getDefaultGeometry();
  String pointValues="";
 
  oneCrd = geom.getCoordinate();
  double coorddiff = oneCrd.y - midpoint;
  double newcoord = midpoint-coorddiff;
	  	
  pointValues = Double.toString(oneCrd.x) ;
  pointElement.setAttributeNS(null, "cx", pointValues); 
  pointValues = Double.toString(newcoord) ;
  pointElement.setAttributeNS(null, "cy", pointValues); 
	  	
	  	return pointElement;
   
}



}